package top.honlnk.mapper;

import org.apache.ibatis.annotations.*;
import top.honlnk.pojo.entity.OcrAdminInfo;
import top.honlnk.pojo.entity.RotaSecretKey;
import top.honlnk.pojo.entity.SchoolTimetable;
import top.honlnk.pojo.entity.ServiceStaff;

import java.util.List;

@Mapper
public interface ServiceStaffMapper {

    @Select("select m.mail from service_staff ss join mail m on ss.mail_id = m.id")
    List<String> getServiceStaffMailList();

    @Select("select * from service_staff where account = #{account}")
    ServiceStaff getStaffByAccount(String account);

    @Select("select mail from mail where id = #{mailId}")
    String getStaffMailById(Integer mailId);

    @Select("select * from rota_secret_key")
    List<RotaSecretKey> getAllRota();

    @Select("select * from service_staff where id = #{id}")
    ServiceStaff getStaffById(Integer integer);

    List<SchoolTimetable> getTable(SchoolTimetable schoolTimetable);

    @Select("select * from ocr_admin_info")
    List<OcrAdminInfo> getOcrAdminInfo();

    void setOcrAdminInfo(OcrAdminInfo ocrAdminInfo);

    @Insert("insert into ocr_admin_info(ocr_name, api_key, secret_key, access_token) values(#{ocrName}, #{apiKey}, #{secretKey}, #{accessToken})")
    void addOcrAdminInfo(OcrAdminInfo ocrAdminInfo);

    @Select("select * from ocr_admin_info where id = #{id}")
    OcrAdminInfo getOcrAdminInfoById(int id);

    @Update("update ocr_admin_info set access_token = #{accessToken} where id = #{id}")
    void updateAccessToken(String accessToken, int id);

    @Delete("delete from rota_secret_key where admin_key = #{key}")
    void delRotaSecretKey(String key);

    @Delete("delete from school_timetable where submit_id = #{submitId}")
    void delSchoolTimetable(String submitId);

    @Delete("delete from ocr_admin_info where id = #{id}")
    void delOcrAdminInfo(int id);
}
